package com.xzx.spark.core.transform

import org.apache.spark.{SparkConf, SparkContext}

/**
 *
 * ${DESCRIPTION}
 *
 * @author xinzhixuan
 * @version 1.0
 * @date 2021-06-26 8:39 下午
 */
object Spark013_Intersection_Union_Subtract {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[*]").setAppName("Spark013_Intersection_Union_Subtract")
    val sparkContext = new SparkContext(conf)
    val dataRDD1 = sparkContext.makeRDD(List(1, 2, 3, 4), 2)
    val dataRDD2 = sparkContext.makeRDD(List(3, 4, 5, 6), 4)
    println(dataRDD1.intersection(dataRDD2).collect().mkString(","))
    println(dataRDD1.union(dataRDD2).collect().mkString(","))
    println(dataRDD1.subtract(dataRDD2).collect().mkString(","))


    sparkContext.stop()
  }
}
